This invention relates generally to databases, and more particularly to enabling multiple concurrent read-only access to database records.
A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever. The following notice applies to the software and data as described below and in the drawing hereto: Copyright(copyright) 1997, Microsoft Corporation, All Rights Reserved.
Existing database systems employ a database manager that control reads and writes on the database records to guarantee consistency of the data. A transaction issues a record request to the database manager which is executed by switching between the context for the transaction and that for the database manager, typically a very expensive operation in terms of processing cycles. The reverse context switch is performed when the database manager completes the request and returns data to the transaction. However, when a transaction is only reading data and not making changes, the context switch introduces unnecessary overhead and slows the processing of the read-only transaction.
When the database manager immediately changes the data in the database in response to an update request, the database manager must reverse the changes using a rollback mechanism if the requesting transaction aborts. Therefore, in order to present a consistent view of the data to another transaction, the database manager either denies access to the changed data until the modifying transaction commits the changes, or permits the other transaction access to the data but must also rollback the other transaction if the modifying transaction aborts. The processing of read-only transactions is thus slowed when they execute concurrently with transactions that update common data.
Therefore, a database system is needed which permits read-only transactions direct access to data and which presents a consistent view of data to a transaction without the complications involved with standard rollback procedures.
The above-mentioned shortcomings, disadvantages and problems are addressed by the present invention, which will be understood by reading and studying the following specification.
An in-memory database system uses a shared memory to cache records and keys read from a database and controls the updating of the records and keys through a database manager process. When a transaction performs an update, the original, unmodified data is preserved in the shared memory, the new data is written to the shared memory, and a look-aside table for the transaction records the changes. A transaction performs read-only access to the shared memory using its own context while a versioning scheme based on the look-aside tables ensures a read-committed isolation level view of the original, unmodified data until the modifying transaction commits the update. The database manager is responsible for writing the new data into the shared memory and for maintaining the look-aside tables for all transaction which have made modifications to the data in the shared memory. The database manager also writes committed changes to the database and performs rollback on uncommitted changes in the shared memory using the entries in the look-aside table for the committing/aborting transaction. The shared memory is divided into logical pages and short duration page latches are employed to maintain consistency on the page while a transaction or the database manager is reading or writing data on the page.
A method of controlling access to database records which are stored in memory shared among multiple processes is described as creating record and/or index entries in a look-aside table, preserving the original data in the shared memory, and allowing a process access to the modified data if a corresponding record and/or index entries exists in the look-aside table for the process. The method also performs rollback and abort processing using the look-aside table.
The in-memory database system is described as having a plurality of clients which manipulate data, a shared memory for caching the data, an in-memory database manager that creates the look-aside table entries and writes changes to the shared memory. The details of data structures and page latches used by the in-memory database system are given. A particular implementation of the in-memory database system is also described.
The present invention describes systems, clients, servers, methods, and computer-readable media of varying scope. In addition to the aspects and advantages of the present invention described in this summary, further aspects and advantages of the invention will become apparent by reference to the drawings and by reading the detailed description that follows.